<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>分类列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/style/admin.css" media="all">
	<link rel="stylesheet" href="/style/list.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
				<div class="layui-inline">
                    <label class="layui-form-label" id="Ssum">总计：0</label>
                    <label class="layui-form-label" style="width: 40px; padding: 0; margin: 0; height: 40px;  line-height: 40px;">
                        <a onclick="SelectData();">总计</a>
                    </label>
                    <label class="layui-form-label" style="width: 40px; padding: 0; margin: 0; height: 40px;  line-height: 40px;">
                        <a onclick="SelectData1(1);">今天</a>
                    </label>
                    <label class="layui-form-label" style="width: 40px; padding: 0; margin: 0; height: 40px;  line-height: 40px;">
                        <a onclick="SelectData1(2);">昨天</a>
                    </label>
                </div>
            </div>
        </div>

        <div class="layui-card-body">

            <table class="layui-hide" id="test"></table>
			
			<script type="text/html" id="barStatus">
                <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail"  onclick="WinStatus({{d.id}},{{d.state}})">{{d.state==1 ? '启用':'关闭'}}</a>
            </script>
			
			<script type="text/html" id="barLower">
                <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail"  onclick="WinOpenLower({{d.id}})">下级分类</a>
            </script>
			
			<script type="text/html" id="barPic">
                <img src="{{d.pic}}" width="60" height="20" onclick="WinPic('{{d.pic}}');" />
            </script>

            <script type="text/html" id="barDemo">
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail"  onclick="WinOpenEdit({{d.id}})">编辑</a>
                <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick="WinOpenDel({{d.id}})">删除</a>-->
            </script>

        </div>
    </div>
</div>
<script src="/layui/layui.js"></script>
<script src="/layui/jquery.min.js"></script>
<script src="/js/common.js"></script>
<script>
    var table;
    layui.use('table', function(){
        table = layui.table
            ,form = layui.form;

        table.render({
            elem: '#test'
            ,url:'/goods?url=DataReport%2FList'
            ,page: false //开启分页
			,cellMinWidth:80
            ,cols: [[
                {type:'numbers'}
				,{field:'no',title:'编号'}
				,{field:'noName',title:'姓名'}
                ,{field:'num', title:'数量'}
            ]]
            ,id: 'testReload'
            ,done :function (res) {
                $("#Ssum").html("总计："+res.count);
            }
        });

        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });


    });
	
    function SelectData1(i) {
        var startTime="";
        var endTime="";
        var myDate = new Date();
        switch (i) {
            case 1:
                var preDate = new Date(myDate.getTime() - 24*60*60*1000); //前一天
                startTime =  DateConver(preDate);
                endTime= DateConver(myDate);
                break;
            case 2:
                var preDate1 = new Date(myDate.getTime() - 2*24*60*60*1000); //前两天
                var preDate = new Date(myDate.getTime() - 24*60*60*1000); //前一天
                startTime =  DateConver(preDate1);
                endTime= DateConver(preDate);
                break;
            default:
                break;
        }
        var url="/goods?url=DataReport%2FSelf&startTime="+startTime+"&endTime="+endTime;
        // alert(url);
        //执行重载
        table.reload('testReload', {
            url:url
        });
    }

    //日期时间处理
    function DateConver(t) {
        //获取当前年
        var year = t.getFullYear();
        //获取当前月
        var month = t.getMonth() + 1;
        //获取当前日
        var date = t.getDate();
        return year + '-' + conver(month) + "-" + conver(date);
    }

    //日期时间处理
    function conver(s) {
        return s < 10 ? '0' + s : s;
    }

    function SelectData() {
        var url="/goods?url=DataReport%2FList";
        //执行重载
        table.reload('testReload', {
            url:url
        });
    }
	
</script>


</body>
</html>